package top.infopub.mgr.sts.service.impl;

import java.util.Date;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import top.infopub.generic.GenericDao;
import top.infopub.generic.GenericServiceImpl;
import top.infopub.mgr.sts.dao.ProSelfCaeDao;
import top.infopub.mgr.sts.service.ProSelfCaeService;
import top.infopub.mgr.util.DateUtils;
import top.infopub.model.sts.ProSelfCae;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.google.common.collect.Maps;

@Service
public class ProSelfCaeServiceImpl extends GenericServiceImpl<ProSelfCae, String> implements
		ProSelfCaeService {

	@Autowired
	private ProSelfCaeDao proSelfCaeDao;
	
	@Override
	public GenericDao<ProSelfCae, String> getDao() {
		return proSelfCaeDao;
	}

    @Override
    public Page<ProSelfCae> selectProSelfCaeByWhere(Page<ProSelfCae> page, Date stsMonth, String orgId) {
        Map<String, Object> where = Maps.newHashMap();
        where.put("noticeDateStart", stsMonth);
        Date stsMonthEnd = DateUtils.getMonthEnd(stsMonth);
        where.put("noticeDateEnd", stsMonthEnd);
        where.put("hrOrgAreaId", orgId);
        where.put("orderCondition", "NOTICE_DATE desc ");
        PageHelper.startPage(page.getPageNum(), page.getPageSize());
        return (Page<ProSelfCae>)proSelfCaeDao.selectByMapWhere(where);
    }

}